package com.miyu.system.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

//@Configuration
public class RedisConfig {



        @Value("${spring.data.redis.host}")
        private String host;

        @Value("${spring.data.redis.port}")
        private int port;

        @Value("${spring.data.redis.password}")
        private String password;

        @Value("${spring.data.redis.timeout}")
        private int timeout;

        @Value("${spring.data.redis.lettuce.pool.max-idle}")
        private int maxIdle;

        @Value("${spring.data.redis.lettuce.pool.max-wait}")
        private long maxWaitMillis;

//        @Bean
        public JedisPool redisPoolFactory() {
            JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
            jedisPoolConfig.setMaxIdle(maxIdle);
            jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);

            return new JedisPool(jedisPoolConfig, host, port, timeout, password);
        }

}
